package main

import "fmt"

func dominantIndex(nums []int) int {
	if len(nums) < 2 {
		return 0
	}
	var max, second, index = -1, -1, 0
	for i, num := range nums {
		if num > max {
			second, max, index = max, num, i
		} else if num > second {
			second = num
		}
	}
	if max >= second*2 {
		return index
	}
	return -1
}

func main() {
	fmt.Println(dominantIndex([]int{12, 6, 1, 0}))
	fmt.Println(dominantIndex([]int{3, 6, 1, 0}))
}
